<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

<py:def function="page_title"><span py:replace="user">[user]</span></py:def>
<py:def function="head_info"></py:def>
<py:def function="page_parents">
    <a href="${tg.url('/user/index')}">Users</a>
</py:def>

<py:match path="content">
    <table id="user_info" class="info_table">
        <tbody>
            <tr>
                <th>Joined:</th>
                <td><span class="date" py:content="tg.display_date(user.created)">[date]</span></td>
            </tr>
            <tr py:if="'view-int-name' in tg.identity.permissions">
                <th>Internal name:</th>
                <td py:content="user.user_name">[int name]</td>
            </tr>
            <tr py:if="'view-user-email' in tg.identity.permissions">
                <th>Email:</th>
                <td><a href="mailto:${user.email_address}" py:content="user.email_address">[email]</a></td>
            </tr>
        </tbody>
    </table>
    <div id="sect_actions" class="buttons">
        <button py:if="'edit-user' in tg.identity.permissions or tg.identity.user == user" id="edit_button">Edit</button>
        <button py:if="'sudo-login' in tg.identity.permissions and tg.identity.user != user" id="sudo_button">Sudo</button>
        <button py:if="'send-mail' in tg.identity.permissions" id="email_button">Email</button>
    </div>
    <h2 id="sect_profile">Profile</h2>
    <img py:if="user.image" id="user_profile_image" src="${tg.hvz.image_link(user.image)}" alt="User picture" />
    <img py:if="user.image is None" id="user_profile_image" src="${tg.url('/static/images/no-user-picture.png')}" alt="No picture" />
    <div py:if="tg.config('hvz.show_legendary', False) and user.is_legendary" id="legendary" title="This user was a participant in the server's first game.">
        <img src="${tg.url('/static/images/star.png')}" alt="star" />
        Legendary
    </div>
    <py:choose>
        <div py:when="user.profile" py:replace="HTML(tg.plain2html(user.profile))">[profile]</div>
        <p py:otherwise="" class="no_profile">This user has not written a profile.</p>
    </py:choose>
    <h2 id="sect_games">Games</h2>
    <div py:replace="tg.display(game_grid, games)">[Games]</div>
    <h2 id="sect_statistics">Statistics</h2>
    <table id="user_statistics" class="info_table">
        <tbody>
            <tr>
                <th>Total games:</th>
                <td py:content="stats.total_games">[#]</td>
            </tr>
            <tr>
                <th>Total kills:</th>
                <td py:content="stats.total_kills">[#]</td>
            </tr>
            <tr>
                <th>Total times killed:</th>
                <td py:content="stats.total_killed">[#]</td>
            </tr>
            <tr>
                <th>Kills/Killed Ratio:</th>
                <td py:content="stats.kill_ratio">[#]</td>
            </tr>
            <tr py:if="stats.avg_survival is not None">
                <th>Average survival time:</th>
                <td py:content="tg.display_date(stats.avg_survival)">[#]</td>
            </tr>
            <tr py:if="stats.avg_undead is not None">
                <th>Average undead time:</th>
                <td py:content="tg.display_date(stats.avg_undead)">[#]</td>
            </tr>
        </tbody>
    </table>
    <script type="text/javascript">
        // EVENTS //
        safe_connect('edit_button', 'onclick',
            function()
            {
                redirect(${tg.jsencode(tg.hvz.user_link(user, 'edit'))});
            });
        safe_connect('sudo_button', 'onclick',
            function()
            {
                redirect(${tg.jsencode(tg.url('/action.sudo', user_name=user.user_name))});
            });
        safe_connect('email_button', 'onclick',
            function()
            {
                redirect(${tg.jsencode(tg.url('/mail', recipients=[user.email_address]))});
            });
    </script>
</py:match>

<xi:include href="../master.html" />

</html>
